package com.spic.business.ioc.controller;

import com.spic.business.ioc.domain.IocRainfall;
import com.spic.business.ioc.service.IIocRainfallService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 年合计降雨量IOCController
 *
 * @author spic
 * @date 2022-04-14
 */
@RestController
@RequestMapping("/ioc/rainfall")
public class IocRainfallController extends BaseController
{
    @Autowired
    private IIocRainfallService iocRainfallService;

    /**
     * 查询年合计降雨量IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:rainfall:list")
    @GetMapping("/list")
    public TableDataInfo list(IocRainfall iocRainfall)
    {
        startPage();
        List<IocRainfall> list = iocRainfallService.selectIocRainfallList(iocRainfall);
        return getDataTable(list);
    }

    /**
     * 导出年合计降雨量IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:rainfall:export")
//    @Log(title = "年合计降雨量IOC", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IocRainfall iocRainfall) throws IOException
    {
        List<IocRainfall> list = iocRainfallService.selectIocRainfallList(iocRainfall);
        ExcelUtil<IocRainfall> util = new ExcelUtil<IocRainfall>(IocRainfall.class);
        util.exportExcel(response, list, "年合计降雨量IOC数据");
    }

    /**
     * 获取年合计降雨量IOC详细信息
     */
//    @PreAuthorize(hasPermi = "ioc:rainfall:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(iocRainfallService.selectIocRainfallById(id));
    }

    /**
     * 新增年合计降雨量IOC
     */
//    @PreAuthorize(hasPermi = "ioc:rainfall:add")
//    @Log(title = "年合计降雨量IOC", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IocRainfall iocRainfall)
    {
        return toAjax(iocRainfallService.insertIocRainfall(iocRainfall));
    }

    /**
     * 修改年合计降雨量IOC
     */
//    @PreAuthorize(hasPermi = "ioc:rainfall:edit")
//    @Log(title = "年合计降雨量IOC", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IocRainfall iocRainfall)
    {
        return toAjax(iocRainfallService.updateIocRainfall(iocRainfall));
    }

    /**
     * 删除年合计降雨量IOC
     */
//    @PreAuthorize(hasPermi = "ioc:rainfall:remove")
//    @Log(title = "年合计降雨量IOC", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(iocRainfallService.deleteIocRainfallByIds(ids));
    }
}
